package cn.edu.service.impl;

import cn.edu.dao.lead_ProjectDao;
import cn.edu.dao.lead_thesisDao;
import cn.edu.domain.PageBean;
import cn.edu.domain.research_project;
import cn.edu.domain.thesis;
import cn.edu.service.lead_ProjectService;
import cn.edu.service.lead_thesisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Davey chan
 */
@Service
public  class lead_ProjectServiceImpl implements lead_ProjectService {
  @Autowired
private lead_ProjectDao projectDao;
    @Override
    public PageBean<research_project> selectByPageAndcondition(int currentPage, int pageSize, research_project t) {
        int begin=(currentPage-1)*pageSize;
//        计算查询的条目数
        int size =pageSize;
        String projectName = t.getProjectName();
        if(projectName !=null && projectName.length()>0){
            t.setProjectName("%"+projectName+"%");
        }
        String projectDir = t.getProjectDir();
        if(projectDir !=null && projectDir.length()>0){
            t.setProjectDir("%"+projectDir+"%");

        }
        String academy = t.getAcademyName();
        if(academy !=null && academy.length()>0){
            t.setAcademyName("%"+academy+"%");

        }
        List<research_project> rows = projectDao.selectBypage(begin, size,t);
//        查询总记录数
        int totalCount =projectDao.selectTotalCount(t);
//封装pageBean
        PageBean<research_project> pageBean=new PageBean<>();
        pageBean.setRows(rows);
        pageBean.setTotalCount(totalCount);
        return pageBean;
    }


}
